package org.rcgwt.client.ui.panels;

import com.google.gwt.user.client.DOM;
import com.google.gwt.user.client.Element;
import com.google.gwt.user.client.ui.SimplePanel;

public class FieldSet extends SimplePanel {
	private Element legend;

	public FieldSet() {
		super(DOM.createFieldSet());

		// FieldSet CSS class
		getElement().setClassName("rcgwt-fieldset");

		// Create a legend to hold the title
		legend = DOM.createLegend();
		getElement().appendChild(legend);

	}

	public String getTitle() {
		return legend.getInnerText();
	}

	public void setTitle(String title) {
		if (title != null && title.length() > 0) {
			legend.setInnerText(title);
		} else {
			legend.setInnerText(null);
		}
	}
}
